<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>弹窗</title>
    <script src="__PUBLIC__/Admin/js/jquery.min.js"></script>
    <script src="__PUBLIC__/Admin/js/jquery.form.js"></script>
    <!-- <link rel="stylesheet" href="__PUBLIC__/Admin/css/font-awesome.min93e3.css"> -->
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/bootstrap-grid.min.css">
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/bootstrap-reboot.min.css">
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/bootstrap.css">
    <script src="__PUBLIC__/Admin/js/bootstrap.bundle.min.js"></script>
    <script src="__PUBLIC__/Admin/js/bootstrap.min.js"></script>
    <script src="__PUBLIC__/Common/layer/layer.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/style.css">
    <script src="__PUBLIC__/Admin/js/script.js"></script>
    <style>
    .btn-list{
   display: block;
    text-align: center;
    margin: auto;
    width: 500px;
    }
    #submit{
        width: 160px;
        margin: 30px auto 0 auto;
        display: block;
    }
    </style>
</head>
<body>
<!-- <form class="lay" action="" method="post" id=""> -->
    <div class="head-title">
        <div>龙</div>
        <div>虎</div>
    </div>
    <div class="content">
        <div class="fl zhu">
            <table class="table" style="background-color:rgba(0, 0, 0, 0.05);">

                <tbody>
                <tr>
                    <td>
                        <div class="select select1">
                            <select class="list list-s1">
                                <option value="黑">黑</option>
                                <option value="红">红</option>
                                <option value="花">花</option>
                                <option value="片">片</option>
                                <option value=""></option>
                            </select>
                        </div>
                        <div class="select select2">
                        <select class="list list-s2">
                            <option value="A">A</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="J">J</option>
                            <option value="Q">Q</option>
                            <option value="K">K</option>
                            <option value=""></option>
                        </select>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="fr xin">
            <table class="table" style="background-color:rgba(0, 0, 0, 0.05);">
                <tbody>
                <tr>
                    <td>
                        <div class="select select7">
                            <select class="list list-s1">
                                <option value="黑">黑</option>
                                <option value="红">红</option>
                                <option value="花">花</option>
                                <option value="片">片</option>
                                <option value=""></option>
                            </select>
                        </div>
                        <div class="select select8">
                            <select class="list list-s2">
                                <option value="A">A</option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                                <option value="7">7</option>
                                <option value="8">8</option>
                                <option value="9">9</option>
                                <option value="10">10</option>
                                <option value="J">J</option>
                                <option value="Q">Q</option>
                                <option value="K">K</option>

                                <option value=""></option>
                            </select>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="btn-list">
        <label class="radio-inline dejiang " style="color:red;">和</label>

    </div>
    <div class="submit-container">
        <button type="submit" id="submit" istype="1" class="btn btn-outline-success">提交</button>
    </div>
<!-- </form> -->
<script>
    // console.log(window.location)
    $(function () {
        $(".list").change(function(){
            chaxun();
        } );
        //判断结果
        function chaxun(){
            var type=$('#submit').attr('istype');
            var list_s1 = $('.select1 option:selected').text();
            var list_s2 = $('.select2 option:selected').text();

            var list_s7 = $('.select7 option:selected').text();
            var list_s8 = $('.select8 option:selected').text();
            var txt = {
                "龙": [list_s1, list_s2],
                "虎": [list_s7, list_s8],

            };
            $.ajax({
                url: "/Admin/Hold/chaxun",
                type: "post",
                cache: false,
                data: {
                    type: type,
                    txt:JSON.stringify(txt)
                },
                dataType: "json",
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                success: function (req) {
                    console.log(req);
                    $('.dejiang').html(req['data']);


                },
                //请求出错处理。注意：有差错时才执行程序体，才会出现alert弹框
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    // alert('错了339');
                    console.log('错了339');
                },
            })
        }
        //录入结果
        $('#submit').click(function () {
            var period_number = getQueryString("period_number");
            var type=$('#submit').attr('istype');

            var list_s1 = $('.select1 option:selected').text();
            var list_s2 = $('.select2 option:selected').text();

            var list_s7 = $('.select7 option:selected').text();
            var list_s8 = $('.select8 option:selected').text();
            var txt = {
                "龙": [list_s1, list_s2],
                "虎": [list_s7, list_s8],
            };
            $.ajax({
                url: "/Admin/Hold/enter",
                type: "post",
                cache: false,
                data: {
                    period_number:period_number,
                    type: type,
                    txt:JSON.stringify(txt)
                },
                dataType: "json",
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                success: function (req) {
                    console.log(req.msg)
                    if(req.msg == '录入成功'){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        window.parent.location.reload()
                        parent.layer.close(index);

                    }

                },
                //请求出错处理。注意：有差错时才执行程序体，才会出现alert弹框
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert('a')
                },
            })
        });
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            console.log(r);
            if (r != null) return unescape(r[2]);
            return null;
        }
    });

</script>
</body>
</html>